/*
 * MembershipBO.java
 *
 * Created on February 12, 2007, 9:10 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package edu.byu.isys413.group1E.data;

import java.util.Date;
import java.util.*;

/** This object contains the data needed for a membership.
 *
 * @author Travis Kulbeth
 */
public class MembershipBO {
    
    private String membershipID = "";
    private String creditCardType = "";
    private String creditCardNum = "";
    private int creditCardExpMonth = 0;
    private int creditCardExpYear = 0;
    private String memberStartDate = null;
    private String memberExpireDate = null;
    private String buExpDate = null;
    private double buSize = 0.0;
    private String membPwd = null;
    private CustomerBO cust = null;
    private ArrayList<AreaOfInterestBO> interestList = null;
    private boolean alreadyInDB = false;
    private boolean isDirty = true;
    
    /**
     * Creates a new instance of MembershipBO
     * @param memberID contains the id for the member
     */
    MembershipBO(String memberID){
        setAlreadyInDB(false);
        setIsDirty(true);
        this.membershipID = memberID;
        this.membPwd = "password";
    }
    
    /**
     * Creates a MembershipBO using parameters retrieved from the UI or DB
     * @param memberID contains the membership id
     * @param creditCardNum contains the credit card number on file for the member
     * @param startDate contains the start date for the membership
     * @param expireDate contains the expiration date for the membership
     * @param cust contains the customer object that this membership pertains to
     */
    MembershipBO(String memberID, String creditCardNum, String startDate, String expireDate, CustomerBO cust) {
        setMembershipID(memberID);
        setCreditCardNum(creditCardNum);
        setMemberStartDate(startDate);
        setMemberExpireDate(expireDate);
        this.setMembPwd("password");
        setAlreadyInDB(false);
    }
    

    /** Returns the customer object for this membership
     * 
     * @return cust
     */
    public CustomerBO getCust() {
        return cust;
    }

    /** Sets the customer object for this membership.
     * 
     * @param cust contains a customer object
     */
    public void setCust(CustomerBO cust) {
        setIsDirty(true);
        this.cust = cust;
    }

    /** Returns the list of areas of interest
     * 
     * @return an ArrayList of AreaOfInterestBO objects
     */
    public ArrayList<AreaOfInterestBO> getInterestList() {
        return interestList;
    }

    /** Adds an AreaOfInterestBO to the list for this membersihp
     * 
     * @param newInterest contains the new AreaOfInterestBO to be added
     */
    public void addInterest(AreaOfInterestBO newInterest) {
        setIsDirty(true);
        if(this.getInterestList() == null){
            this.setInterestList(new ArrayList<AreaOfInterestBO>());
        }
        this.getInterestList().add(newInterest);
    }
    
    /** Removes an indicated AreaOfInterestBO from the member's list
     * 
     * @param index contains the index in the list of the AOI objects
     */
    public void removeInterest(int index) {
        this.getInterestList().remove(index);
    }

    /** Returns the membership ID
     * 
     * @return membershipID
     */
    public String getMembershipID() {
        return membershipID;
    }

    /** Sets the membershipID
     * 
     * @param membershipID contains the id for the membership
     */
    public void setMembershipID(String membershipID) {
        setIsDirty(true);
        this.membershipID = membershipID;
    }

    /** Returns the credit card type
     * 
     * @return creditCardType
     */
    public String getCreditCardType() {
        return creditCardType;
    }

    /** Sets the credit card type
     * 
     * @param creditCardType contains the credit card type to be used
     */
    public void setCreditCardType(String creditCardType) {
        setIsDirty(true);
        this.creditCardType = creditCardType;
    }

    /** Returns the Credit Card Number
     * 
     * @return creditCardNum
     */
    public String getCreditCardNum() {
        return creditCardNum;
    }

    /** Set the credit card 
     * 
     * @param creditCardNum contains the credit card number for this member
     */
    public void setCreditCardNum(String creditCardNum) {
        setIsDirty(true);
        this.creditCardNum = creditCardNum;
    }

    /** Returns the credit card's expiration month
     * 
     * @return the credit Card's expiration month
     */
    public int getCreditCardExpMonth() {
        return creditCardExpMonth;
    }

    /** Sets the credit card's expiration month
     * 
     * @param creditCardExpMonth contains the creditCardExpMonth
     */
    public void setCreditCardExpMonth(int creditCardExpMonth) {
        setIsDirty(true);
        this.creditCardExpMonth = creditCardExpMonth;
    }

    /** Returns the credit card expiration year
     * 
     * @return creditCardExpYear
     */
    public int getCreditCardExpYear() {
        return creditCardExpYear;
    }

    /** Sets the credit card expiration year
     * 
     * @param creditCardExpYear contains the credit card expiration year
     */
    public void setCreditCardExpYear(int creditCardExpYear) {
        setIsDirty(true);
        this.creditCardExpYear = creditCardExpYear;
    }

    /** Returns the membership start date
     * 
     * @return memberStartDate
     */
    public String getMemberStartDate() {
        return memberStartDate;
    }

    /** Sets the membership start date
     * 
     * @param memberStartDate contains the start date
     */
    public void setMemberStartDate(String memberStartDate) {
        setIsDirty(true);
        this.memberStartDate = memberStartDate;
    }

    /** Return the membership expiration date
     * 
     * @return memberExpireDate
     */
    public String getMemberExpireDate() {
        return memberExpireDate;
    }

    /** Sets the membership expiration date
     * 
     * @param memberExpireDate contains the expiration date
     */
    public void setMemberExpireDate(String memberExpireDate) {
        setIsDirty(true);
        this.memberExpireDate = memberExpireDate;
    }

    /** Sets the membership's interest list
     * 
     * @param interestList contains a list of the member's areas of interest
     */
    public void setInterestList(ArrayList interestList) {
        setIsDirty(true);
        this.interestList = interestList;
    }

    /** Indicates if the object has already been saved to the DB
     * 
     * @return alreadyInDB
     */
    public boolean isAlreadyInDB() {
        return alreadyInDB;
    }

    /** Sets if the object has already been saved to the DB.
     * 
     * @param alreadyInDB indicates if the object is already in the DB
     */
    public void setAlreadyInDB(boolean alreadyInDB) {
        setIsDirty(true);
        this.alreadyInDB = alreadyInDB;
    }

    /** Indicates if information has changed
     *@return isDirty
     */
    public boolean isIsDirty() {
        return isDirty;
    }

    /** Sets the isDirty variable to indicate if information has changed
     *@param isDirty indicates if info has been changed
     */
    public void setIsDirty(boolean isDirty) {
        this.isDirty = isDirty;
    }

    /** Returns the backup expiration date
     *@return buExpDate
     */
    public String getBuExpDate() {
        return buExpDate;
    }

    /** Sets the backup expiration date for this member
     *@param buExpDate contains the expiration date for the backup
     */
    public void setBuExpDate(String buExpDate) {
        setIsDirty(true);
        this.buExpDate = buExpDate;
    }

    /** Returns the backup size for this member
     *@return buSize
     */
    public double getBuSize() {
        return buSize;
    }

    /** Sets the backup size for this member
     *@param buSize contains the size of the backup.
     */
    public void setBuSize(double buSize) {
        setIsDirty(true);
        this.buSize = buSize;
    }
    
    /** Returns this member's password
     *@return membPwd
     */
    public String getMembPwd(){
        return this.membPwd;
    }
      
    /** Sets the password for this member
     *@param pwd contains the password for this member
     */
    public void setMembPwd(String pwd){
        setIsDirty(true);
        this.membPwd = pwd;
    }
    
    /**
     * Checks the password entered at the login screen to see if
     * it's correct or not.
     * 
     * @return isValid
     * @param pwd contains the password entered
     */
    public boolean validatePwd(String pwd){
        boolean isValid = false;
        if(pwd.equals(this.membPwd)){
            isValid = true;
        }
        return isValid;
    }
}
